package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.BMLDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BMLController {
    @RequestMapping("/v1/bml/getBMLV1")
    @ResponseBody
    public String getBMLV1(double height, double weight){
        double BML = weight/(height*height);
        if (BML<18.5) {
            return "偏瘦";
        }else if (BML<24){
            return "正常";
        }else if(BML<27){
            return "微胖";
        }
        return "该减肥了";
    }

    @RequestMapping("/v1/bml/getBMLV2")
    @ResponseBody
    public String getBMLV2(BMLDTO bmldto){
        double weight = bmldto.getWeight();
        double height = bmldto.getHeight();
        double BML = weight/(height*height);
        if (BML<18.5) {
            return "偏瘦:"+BML;
        }else if (BML<24){
            return "正常:"+BML;
        }else if(BML<27){
            return "微胖:"+BML;
        }
        return "该减肥了:"+BML;
    }
}
